package com.etooling.pdm.entity;

import com.etooling.framework.entity.Employee;
import com.etooling.framework.svo.AbstractEntity;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;

@Entity
@Data
@Table(name = "t_goods_specs_stock_record", schema = "pdm")
public class GoodsSpecsStockRecord extends AbstractEntity {
    private static final long serialVersionUID = 1L;
    public static final String OPERATION_TYPE_IN = "入库";  // 入库
    public static final String OPERATION_TYPE_OUT = "出库";  // 出库
    public static final String STATUS_NORMAL = "正常";  // 正常
    public static final String STATUS_REVOKED = "已撤回";  // 已撤回

    private GoodsSpecs goodsSpecs;  // 关联的物料
    private Employee operator;     // 操作人，谁操作出库或者入库的
    private String companyId;      // 所属公司ID

    private String operationType;  // 出库还是入库：IN-入库，OUT-出库
    private Integer stockNum;       // 本次出入库的数量
    private String stockType;      // 出入库类型，例如：领料、进货、出售
    private Date recordTime;       // 出入库的时间
    private String memo;           // 备注信息

    private String status;        // 记录状态：NORMAL-正常，REVOKED-已撤回
    private String revokeBy;      // 撤回人ID
    private Date revokeTime;      // 撤回时间
    private String revokeReason;  // 撤回原因

    @ManyToOne(targetEntity = GoodsSpecs.class, fetch = FetchType.LAZY)
    @JoinColumn(name = "goods_specs_id")
    public GoodsSpecs getGoodsSpecs() {
        return goodsSpecs;
    }

    @ManyToOne(targetEntity = Employee.class, fetch = FetchType.LAZY)
    @JoinColumn(name = "operator_id")
    public Employee getOperator() {
        return operator;
    }

    @Column(columnDefinition = "text")
    public String getMemo() {
        return memo;
    }
}